package com.itcast.n1_内存调优;

import java.util.ArrayList;

/**
 * @program: jvm
 * @description:
 * @author: flyduck
 * @create: 2024-10-16 16:02
 **/
public class  Test07_内存泄漏问题2_静态内部类不会持有外部类不会有内存泄漏问题{
    public static void main(String[] args) throws InterruptedException {
        int count = 0;
        ArrayList<Outer4.Inner4> inner4s = new ArrayList<>();
        while (true) {
            if(count++ % 100 == 0){
                Thread.sleep(10);
            }
            inner4s.add(new Outer4.Inner4());
        }
    }
}

class Outer4 {
    private byte[] bytes = new byte[1024 * 1024]; //外部类持有数据
    private static String name  = "测试";
    static class Inner4 {
        private String name;
        public Inner4() {
        }
    }
}
